#define _CRT_SECURE_NO_WARNINGS
#include<string.h>
#include<stdio.h>
void Turn_arr(char* str, int k)
{
    int i = 0, j = k - 1;
    while (i < j)
    {
        char tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
        i++; j--;
    }
}
char* reverseStr(char* s, int k) {
    int slow = 0; int fast = 0;
    int len = strlen(s);
    while (fast < len)
    {
        fast += 2 * k;
        if (fast > len)
        {
            break;
        }
        else
        {
            Turn_arr(&s[slow], k);
            slow = fast;
        }
    }
    if (s[slow] == '\0')
    {
        return s;
    }
    else {
        int len2 = strlen(&s[slow]);
        if (len2 < k)
        {
            Turn_arr(&s[slow], len2);
        }
        else {
            Turn_arr(&s[slow], k);
        }
    }
    return s;
}
int main()
{
    char arr[] = "abcd";
    int k = 2;
    char*ret=reverseStr(arr, k);
    printf("%s\n", ret);
    return 0;
}